<template>
  <div class="home-container">
    <!-- 微信访问提示 -->
    <div v-if="$isWechat && showWechatTip" class="wechat-tip-overlay">
      <div class="wechat-tip-content">
        <div class="tip-header">
          <i class="fas fa-exclamation-triangle"></i>
          <h3>访问提示</h3>
        </div>
        <div class="tip-body">
          <p>为了获得更好的体验，建议您：</p>
          <ol>
            <li>点击右上角 <strong>"..."</strong> 按钮</li>
            <li>选择 <strong>"在浏览器中打开"</strong></li>
            <li>或复制链接到其他浏览器访问</li>
          </ol>
        </div>
        <div class="tip-footer">
          <button class="tip-btn" @click="showWechatTip = false">我知道了</button>
          <button class="tip-btn primary" @click="copyUrl">复制链接</button>
        </div>
      </div>
    </div>
    
    <!-- Header -->
    <div class="header">
      <div class="container">
        <div class="header-content">
          <div class="dynamic-icon">
            <i class="fas fa-home"></i>
          </div>
          <h1 class="main-title">家装无忧</h1>
          <div class="sub-title">全流程服务指南</div>
        </div>
      </div>
    </div>

    <div class="container">
      <!-- Feature Cards -->
      <div class="feature-cards">
        <div class="feature-card">
          <div class="feature-icon">
            <i class="fas fa-road"></i>
          </div>
          <div class="feature-title">3大阶段全程指导</div>
        </div>

        <div class="feature-card">
          <div class="feature-icon">
            <i class="fas fa-dna"></i>
          </div>
          <div class="feature-title">20题DNA精准定位</div>
        </div>

        <div class="feature-card">
          <div class="feature-icon">
            <i class="fas fa-toolbox"></i>
          </div>
          <div class="feature-title">10套专业工具护航</div>
        </div>
      </div>

      <!-- Core Concept -->
      <div class="core-concept-section">
        标准化工具包解决80%基础问题，专业咨询守护20%关键决策
      </div>

      <!-- Stages -->
      <div class="stage" v-for="(stage, index) in stages" :key="index">
        <div class="stage-header">
          <div class="stage-title-content">
            <div class="stage-main-title">
              <i :class="stage.icon"></i> {{ stage.title }}
            </div>
            <div class="stage-subtitle">{{ stage.subtitle }}</div>
          </div>
        </div>

        <div class="stage-content">
          <div class="stage-section" v-for="(section, sIndex) in stage.sections" :key="sIndex">
            <h4><i :class="section.icon"></i> {{ section.title }}</h4>
            <p>{{ section.content }}</p>
          </div>

          <div class="action-buttons">
            <div class="action-btn" @click="openToolsDialog(index)">
              <i class="fas fa-book-open"></i>
              <span>工具包介绍</span>
            </div>
            <div class="action-btn" @click="openServiceDialog(index)">
              <i class="fas fa-users"></i>
              <span>人工服务介绍</span>
            </div>
          </div>
        </div>
      </div>

      <button class="price-button" @click="toServicePrice">
        <i class="fas fa-tags"></i> 了解服务价格
      </button>

      <div class="disclaimer">
        <strong>特别声明：</strong> 本服务基于从业经验及行业现状分析，旨在为客户提供尽可能多的指导和帮助。但这不能替代法律咨询和专业监理机构。
      </div>
    </div>

    <div class="footer">© 2025 专业家装服务系统 / 保护知识产权 . 盗版必究</div>
  </div>
</template>

<script>
export default {
  name: 'HomeView',
  data() {
    return {
      showWechatTip: this.$isWechat, // 在微信中显示提示
      stages: [
        {
          title: '阶段一：需求定位',
          subtitle: '精准定位装修需求，选择合适的装企类型',
          icon: 'fas fa-search',
          sections: [
            {
              title: '核心目标',
              icon: 'fas fa-bullseye',
              content: '解决"我该找哪种类型的装企？"这一关键问题，为后续决策奠定基础。'
            },
            {
              title: '场景痛点',
              icon: 'fas fa-exclamation-triangle',
              content: '盲目筛选耗时耗力，不了解市场情况与各服务类型差异，增加选择难度。难以选择，甚至错误选择。'
            },
            {
              title: '核心流程',
              icon: 'fas fa-sitemap',
              content: '通过测评应用答题，对照、匹配的流程，定位自身装修需求。'
            },
            {
              title: '目标意义',
              icon: 'fas fa-flag-checkered',
              content: '精准定位装企类型，提高选择效率，避免后续不必要的麻烦。'
            }
          ]
        },
        {
          title: '阶段二：理性决策',
          subtitle: '理性选择靠谱装企，规避决策风险',
          icon: 'fas fa-check-circle',
          sections: [
            {
              title: '核心目标',
              icon: 'fas fa-bullseye',
              content: '解决"具体选哪家公司才靠谱？"理性决策确保装修质量。'
            },
            {
              title: '场景痛点',
              icon: 'fas fa-exclamation-triangle',
              content: '报价单看不懂，合同条款暗藏陷阱，增加决策难度。'
            },
            {
              title: '核心流程',
              icon: 'fas fa-sitemap',
              content: '通过初筛、否决、评估的流程，筛选出靠谱装企。'
            },
            {
              title: '决策重要性',
              icon: 'fas fa-balance-scale',
              content: '理性决策选对装企，可有效避免装修过程中的诸多问题。'
            }
          ]
        },
        {
          title: '阶段三：安全落地',
          subtitle: '确保装修施工过程有效执行，避免被坑',
          icon: 'fas fa-home',
          sections: [
            {
              title: '核心目标',
              icon: 'fas fa-bullseye',
              content: '解决"施工过程如何有效执行不被坑？"保障装修效果。'
            },
            {
              title: '场景痛点',
              icon: 'fas fa-exclamation-triangle',
              content: '隐蔽工程偷工减料、整改推诿扯皮等，影响装修工期及质量。'
            },
            {
              title: '核心流程',
              icon: 'fas fa-sitemap',
              content: '通过验收、取证、整改的流程，确保施工过程合规。'
            },
            {
              title: '落地重要性',
              icon: 'fas fa-check-double',
              content: '保障施工过程顺利，实现预期装修效果。'
            }
          ]
        }
      ],
      priceData: [
        {
          category: '工具包',
          service: '需求定位工具包',
          price: '¥199'
        },
        {
          category: '工具包',
          service: '理性决策工具包',
          price: '¥299'
        },
        {
          category: '工具包',
          service: '安全落地工具包',
          price: '¥399'
        },
        {
          category: '服务包',
          service: '专属管家咨询（1小时）',
          price: '¥500'
        },
        {
          category: '服务包',
          service: '现场验收指导（1次）',
          price: '¥800'
        },
        {
          category: '套餐',
          service: '全流程护航套餐',
          price: '¥1999'
        }
      ]
    }
  },
  methods: {
    goToDnaTest() {
      this.$router.push('/dna-test')
    },
    goToComparison() {
      this.$router.push('/company-comparison')
    },
    toServicePrice() {
      this.$router.push('/service-price')
    },
    openToolsDialog(stageIndex) {
      // 阶段一的工具包已经存在，跳转到现有页面
      if (stageIndex === 0) {
        this.$router.push('/tools-detail')
      } else if (stageIndex === 1) {
        // 阶段二的工具包
        this.$router.push('/stage2-tools')
      } else if (stageIndex === 2) {
        // 阶段三的工具包
        this.$router.push('/stage3-tools')
      }
    },
    openServiceDialog(stageIndex) {
      if (stageIndex === 0) {
        // 阶段一的人工服务
        this.$router.push('/stage1-service')
      } else if (stageIndex === 1) {
        // 阶段二的人工服务
        this.$router.push('/stage2-service')
      } else if (stageIndex === 2) {
        // 阶段三的人工服务
        this.$router.push('/stage3-service')
      }
    },
    copyUrl() {
      const url = window.location.href
      if (navigator.clipboard) {
        navigator.clipboard.writeText(url).then(() => {
          this.$message.success('链接已复制到剪贴板')
        }).catch(() => {
          this.fallbackCopyUrl(url)
        })
      } else {
        this.fallbackCopyUrl(url)
      }
    },
    fallbackCopyUrl(url) {
      // 兼容旧浏览器的复制方法
      const textArea = document.createElement('textarea')
      textArea.value = url
      document.body.appendChild(textArea)
      textArea.select()
      try {
        document.execCommand('copy')
        this.$message.success('链接已复制到剪贴板')
      } catch (err) {
        this.$message.error('复制失败，请手动复制')
      }
      document.body.removeChild(textArea)
    }
  }
}
</script>
<style scoped>
/* 微信访问提示样式 */
.wechat-tip-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.wechat-tip-content {
  background: white;
  border-radius: 12px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.tip-header {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white;
  padding: 20px;
  text-align: center;
}

.tip-header i {
  font-size: 24px;
  margin-bottom: 8px;
  display: block;
}

.tip-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.tip-body {
  padding: 20px;
}

.tip-body p {
  margin-bottom: 15px;
  color: #333;
  font-size: 14px;
  line-height: 1.5;
}

.tip-body ol {
  margin: 0;
  padding-left: 20px;
  color: #555;
}

.tip-body li {
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.4;
}

.tip-footer {
  padding: 15px 20px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.tip-btn {
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  color: #666;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
}

.tip-btn:hover {
  background: #f5f5f5;
}

.tip-btn.primary {
  background: #2e7d32;
  color: white;
  border-color: #2e7d32;
}

.tip-btn.primary:hover {
  background: #1b5e20;
}

@media (max-width: 480px) {
  .wechat-tip-content {
    margin: 20px;
  }
  
  .tip-footer {
    flex-direction: column;
  }
  
  .tip-btn {
    width: 100%;
    text-align: center;
  }
}

.footer {
  position: fixed;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 40px;
  background-color: #FFF;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
}

/* 家装无忧主页样式 */
.home-container {
  min-height: 100vh;
  padding-bottom: 50px;
}

.header {
  background: var(--primary-color);
  color: white;
  padding: 12px 0;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-medium);
}

.header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.main-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 1.5px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.sub-title {
  font-size: 12px;
  font-weight: 400;
  margin-top: 4px;
  opacity: 0.9;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.dynamic-icon {
  position: absolute;
  top: 10px;
  left: 15px;
  font-size: 32px;
  color: #ffd54f;
  /* animation: spin 4s infinite linear; */
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.feature-cards {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.feature-cards::-webkit-scrollbar {
  display: none;
}

.feature-card {
  flex: 0 0 30%;
  min-width: 100px;
  background: #f8fef8;
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
  height: 75px;
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(to right, #81c784, #4caf50, #2e7d32);
}

.feature-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 5px;
  color: var(--primary-color);
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(76, 175, 80, 0.2);
}

.feature-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1.2;
}

.core-concept-section {
  background: #f9f9f9;
  border-radius: 10px;
  padding: 10px;
  margin: 12px 0;
  text-align: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
  font-size: 13px;
  color: var(--text-medium);
  font-weight: 500;
  line-height: 1.4;
}

.stage {
  margin-bottom: 20px;
  position: relative;
  animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stage:nth-child(1) {
  animation-delay: 0.1s;
}

.stage:nth-child(2) {
  animation-delay: 0.2s;
}

.stage:nth-child(3) {
  animation-delay: 0.3s;
}

.stage-header {
  background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
  color: white;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
}

.stage-title-content {
  display: flex;
  flex-direction: column;
}

.stage-main-title {
  font-size: 15px;
  display: flex;
  align-items: center;
}

.stage-main-title i {
  margin-right: 8px;
  font-size: 16px;
}

.stage-subtitle {
  font-size: 12px;
  opacity: 0.9;
  font-weight: normal;
  margin-top: 3px;
  margin-left: 24px;
}

.stage-content {
  padding: 14px;
  background: white;
}

.stage-section {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed #e0e0e0;
  position: relative;
}

.stage-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.stage-section h4 {
  color: var(--primary-color);
  font-size: 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
}

.stage-section h4 i {
  margin-right: 8px;
  font-size: 14px;
  width: 20px;
  text-align: center;
}

.stage-section p {
  font-size: 12px;
  color: var(--text-medium);
  padding-left: 28px;
  line-height: 1.4;
}

.action-buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.action-btn {
  flex: 1;
  padding: 12px 8px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 12px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-light);
  background: linear-gradient(to bottom, #c8e6c9, #a5d6a7);
  color: var(--primary-color);
  border: none;
}

.action-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(46, 125, 50, 0.25);
}

.action-btn:active {
  transform: translateY(1px);
}

.action-btn i {
  font-size: 20px;
  margin-bottom: 6px;
}

.price-button {
  display: block;
  width: 100%;
  padding: 14px;
  background: linear-gradient(to right, #4caf50, #2e7d32);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin: 20px 0;
  box-shadow: 0 4px 10px rgba(76, 175, 80, 0.3);
}

.price-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(46, 125, 50, 0.25);
}

.price-button:active {
  transform: translateY(1px);
}

.disclaimer {
  background: #f5f5f5;
  padding: 10px;
  margin: 16px 0;
  border-radius: 8px;
  font-size: 10px;
  color: #ff0000;
  line-height: 1.4;
  text-align: center;
}

/* 价格对话框样式 */
.price-dialog :deep(.el-dialog__body) {
  padding: 20px;
}

.price-category {
  font-weight: 600;
  color: var(--primary-color);
}

.price-amount {
  font-weight: 600;
  color: #f56c6c;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .feature-cards {
    gap: 6px;
  }

  .feature-card {
    flex: 0 0 31%;
    padding: 8px 5px;
    min-width: 85px;
    height: 70px;
  }

  .feature-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
    margin-bottom: 4px;
  }

  .feature-title {
    font-size: 10px;
  }

  .action-buttons {
    gap: 8px;
  }

  .action-btn {
    padding: 10px 6px;
    font-size: 11px;
  }

  .action-btn i {
    font-size: 18px;
    margin-bottom: 5px;
  }

  .main-actions {
    flex-direction: column;
    gap: 10px;
  }

  .main-action-btn {
    width: 100% !important;
  }

  .stage-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stage-subtitle {
    margin-left: 0;
    margin-top: 3px;
  }

  .main-title {
    font-size: 20px;
  }

  .sub-title {
    font-size: 11px;
  }

  .dynamic-icon {
    font-size: 28px;
  }
}

@media (min-width: 769px) {
  .feature-cards {
    justify-content: center;
    gap: 20px;
  }

  .feature-card {
    flex: 0 0 180px;
  }
}
</style>
